package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.model.Column;
import com.openbravo.data.model.Field;
import com.openbravo.data.model.PrimaryKey;
import com.openbravo.data.model.Row;
import com.openbravo.data.model.Table;
import com.openbravo.data.user.BrowsableEditableData;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.panels.JPanelTable2;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class AttributeUsePanel extends JPanelTable2
{
  private AttributeUseEditor editor;
  private AttributeSetFilter filter;

  protected void init()
  {
    this.filter = new AttributeSetFilter();
    this.filter.init(this.app);
    this.filter.addActionListener(new ReloadActionListener( ));
    this.row = new Row(new Field[] { new Field("ID", Datas.STRING, Formats.STRING), new Field("ATRIBUTESET_ID", Datas.STRING, Formats.STRING), new Field("ATTRIBUTE_ID", Datas.STRING, Formats.STRING), new Field(AppLocal.getIntString("label.order"), Datas.INT, Formats.INT, false, true, true), new Field(AppLocal.getIntString("label.name"), Datas.STRING, Formats.STRING, true, true, true) });
    Table localTable = new Table("ATTRIBUTEUSE", new Column[] { new PrimaryKey("ID"), new Column("ATTRIBUTESET_ID"), new Column("ATTRIBUTE_ID"), new Column("LINENO") });
    this.lpr = this.row.getListProvider(this.app.getSession(), "SELECT ATTUSE.ID, ATTUSE.ATTRIBUTESET_ID, ATTUSE.ATTRIBUTE_ID, ATTUSE.LINENO, ATT.NAME FROM ATTRIBUTEUSE ATTUSE, ATTRIBUTE ATT WHERE ATTUSE.ATTRIBUTE_ID = ATT.ID AND ATTUSE.ATTRIBUTESET_ID = ? ORDER BY LINENO", this.filter);
    this.spr = this.row.getSaveProvider(this.app.getSession(), localTable);
    this.editor = new AttributeUseEditor(this.app, this.dirty);
  }

  public void activate()
    throws BasicException
  {
    this.filter.activate();
    this.editor.activate();
    startNavigation();
    reload();
  }

  public Component getFilter()
  {
    return this.filter.getComponent();
  }

  public EditorRecord getEditor()
  {
    return this.editor;
  }

  private void reload()
    throws BasicException
  {
    String str = (String)this.filter.createValue();
    this.editor.setInsertId(str);
    this.bd.setEditable(str != null);
    this.bd.actionLoad();
  }

  public String getTitle()
  {
    return AppLocal.getIntString("Menu.AttributeUse");
  }

  private class ReloadActionListener
    implements ActionListener
  {
    private ReloadActionListener()
    {
    }

    public void actionPerformed(ActionEvent paramActionEvent)
    {
      try
      {
        AttributeUsePanel.this.reload();
      }
      catch (BasicException localBasicException)
      {
      }
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.AttributeUsePanel
 * JD-Core Version:    0.6.0
 */